////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//  Filename:    OuttaThisWorldGuts.h                                         //
//  Developer:   Ryan Sauls                                                   //
//  Create date: 2/22/2005                                                    //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//  Description: This is the class declaration for the slot gut of the        //
//               Australian Slot machine called Outta This World.             //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
//        Copyright (c) 2005 - Realtime Gaming.  All rights reserved.         //
////////////////////////////////////////////////////////////////////////////////

#ifndef __OUTTATHISWORLD_H__
#define __OUTTATHISWORLD_H__

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "slotguts.h"
#include "getrand.h"

class OuttaThisWorldGuts : public SlotGuts
{
public:
	OuttaThisWorldGuts();

	virtual ~OuttaThisWorldGuts();

private:
	// Shared enums between client and server
	#include "OuttaThisWorldCommon.h"

	// Typedef for our base class
	typedef SlotGuts super;

	// Helpful lookup arrays.
	static SpinResult m_aLineWinSpinResults[NUM_VALID_ICONS][6];

	static SpinResult m_aScatterWinSpinResults[6];

	static int32	  s_aScatterMasks[5];

	// Inline functions to use with the arrays that also do
	// bounds checking.
	static SpinResult lookupLineWinSpinResult( uint8 nIconType, uint8 nCount )
	{
		if ( nIconType < NUM_VALID_ICONS && nCount < 6 )
		{
			return m_aLineWinSpinResults[ nIconType ][ nCount ];
		}

		ASSERT( false );
		return EVT_INVALID;
	}

	static SpinResult lookupScatterWinSpinResult( uint8 nCount )
	{
		if ( nCount < 6 )
		{
			return m_aScatterWinSpinResults[ nCount ];
		}

		ASSERT( false );
		return EVT_INVALID;
	}
	
	static uint8 lookupScatterIconCount( SpinResult result )
	{
		switch (result)
		{
		case EVT_SCATTER_NEAR_MISS:
			return 1;
		case EVT_TWO_BLACK_HOLE:
			return 2;
		case EVT_THREE_BLACK_HOLE:
			return 3;
		case EVT_FOUR_BLACK_HOLE:
			return 4;
		case EVT_FIVE_BLACK_HOLE:
			return 5;
		default:
			return 0;
		};
	}

	// Helper functions for classifyStops.
	void tryForJackpot( SlotSpin* spin );
	SpinResult getScatterWinResult( SlotSpin* spin, int32& scatterPositions ) const;
	void evaluateScatterWin( SlotSpin* spin, SpinResult srScatterResult, int32 scatterPositions );
	void evaluateFeatureTrigger( SlotSpin* spin, SpinResult srScatterResult, int32 scatterPositions );

public:
	virtual void classifyStops( SpinLine* spinline, uint8* stops, uint8 bet, uint8 line,
		uint8& rtnresult, uint8& multiplier );

	virtual void classifyScatters( SlotSpin *spin );

    virtual bool8 isValidGuts();

	virtual bool8 processClientData(uint8 bonusGameType, int32 bonusDataCount, int32 *bonusData);

	virtual bool8 hasSavedGames();

	virtual void  getGameModeMultiplierAndNoteId( uint8& nGameModeMultiplier, uint8& nNoteId );

protected:	
    typedef std::map<const SlotIcon*, SlotIcon*> SlotIconSubstitutionMap;
	
	bool8 m_bAllowAlienIconSubstitutions;
	SlotIconSubstitutionMap	m_mapSubstitutionIcons;

	bool8 allocateAlienSubstitionIcons();
    void deallocateAlienSubstitutionIcons();
    void addSubstitutionIcon( const SlotIcon* current );

	// Override of the framework function.
    const SlotIcon* getIcon( uint8 gamemodeID, uint8 reelID, uint8 position ) const;

	virtual bool8 load( Info* info );

	void initializeBonusGame( int32 awardedBonusGames );

	void awardFreeSpins();

	void  setFeatureGameMultiplier(int32 nFeatureGameMultiplier);
	int32 getFeatureGameMultiplier() const;

	void  setBonusPlanetsAwarded( int32 nAwarded );
	int32 getBonusPlanetsAwarded() const;
	int32 getBonusPlanetsRemaining() const;
	int32 getCurrentBonusPlanetIndex() const;
	void  setBonusPlanetWinType( int32 nPick, int32 nWinType );
	int32 getBonusPlanetWinType( int32 nPick ) const;
	void  setBonusPlanetWinAmount( int32 nPick, int32 nAmount ); 
	int32 getBonusPlanetWinAmount( int32 nPick ) const;
	void  setPlanetIDForPick( int32 nPick, int32 nPlanet );
	int32 getBonusPlanetForPick( int32 nPick ) const;

	int32 getBonusPlanetCreditPrizeCount() const;	
	int32 getBonusPlanetFreeGamesPrizeCount() const;

	void  setJewelChestForPick( int32 nPick, int32 nPlanet );
	int32 getJewelChestForPick( int32 nPick ) const;
	void  setJewelPickWinAmount( int32 nPick, int32 nAmount ); 
	int32 getJewelPickWinAmount( int32 nPick ) const;

	void  updateBonusPlanetSelectedMask( int32 nPlanet );
	void  setBonusPlanetSelectedMask( int32 nMask );
	int32 getBonusPlanetSelectedMask() const;
	
	bool  isBonusPlanetSelected( int32 nPlanet ) const;
	
	void  initializeBonusGameResultIndex();
	int32 postIncrementBonusGameResultIndex();
	int32 getBonusGameResultIndex() const;

	void  initializeAliensFoundCount();
	void  incrementAliensFoundCount();
	int32 getAliensFoundCount() const;

	void  initializeCurrentBonusPlanetIndex();
	void  incrementCurrentBonusPlanetIndex();

	bool8 getAlienIconOnReel( uint8 nReel ) const;
	void  setAlienIconOnReel( uint8 nReel, bool8 substitute );
	void  clearAlienIconSubstitutions();

	virtual void preSpinClassifyResults( SlotSpin *spin );
	virtual void postSpinClassifyResults( SlotSpin *spin );

	virtual void initDebugFunctionMap();

	void DebugFeature_SetNextPlanetWin(int32 data);

	static int32 Debug_GetPlanetWinCount();
	static void	 Debug_GetWinType(int32 nPick, int32& nWinType, int32& nMultiplier);
	static bool8 Debug_SpecifiedAlienLocations();

	static int32 g_FeatureOutcomes[MAX_PLANET_PICKS];
	static int32 g_NextPlanet;
};


#endif // __OUTTATHISWORLD_H__
